<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/11/7
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>add</title>
    <link href="//unpkg.com/layui@2.7.6/dist/css/layui.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/layui/layui/layui.js" charset="utf-8"></script>
</head>
<body>
    <div style="margin-top: 25px">
        <form class="layui-form" action="addUser" method="post" enctype="multipart/form-data">
            <div class="layui-form-item">
                <label class="layui-form-label">账号：</label>
                <div class="layui-input-inline">
                    <input type="text" name="account" id="account" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                    <span style="color: red">${accountError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">真实姓名：</label>
                <div class="layui-input-inline">
                    <input type="text" name="realName" id="realName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                    <span style="color: red">${realNameError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码：</label>
                <div class="layui-input-inline">
                    <input type="text" name="password" id="password" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                    <span style="color: red">${passwordError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="2" title="男" checked="">
                    <input type="radio" name="sex" value="1" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出生日期：</label>
                <div class="layui-input-inline">
                    <input type="text" name="birthday" id="birthday" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">电话：</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" id="phone" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">地址：</label>
                <div class="layui-input-inline">
                    <input type="text" name="address" id="address" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色：</label>
                <div class="layui-input-inline">
                    <select name="roleId" lay-filter="aihao">
                        <option value="1">管理系统员</option>
                        <option value="2">店长</option>
                        <option value="3">店员</option>
                    </select>
                </div>
            </div>

            <div>
                证件照：
                <input type="file" name="idPic">
            </div>

            <div class="layui-block">
                <div class="layui-input-block">
                    <button type="submit" id="sub" class="layui-btn" lay-submit="" >添加</button>
                </div>
            </div>
        </form>
    </div>

    <script>

        layui.use(['table','form','jquery','layer'], function(){
            var layer = layui.layer;
            var $ = layui.$;


           if (${msg==false}){
                layer.msg("添加失败",{
                    icon: 2,
                    time: 1000
                })
            }

            $('#account').blur(function () {
                $.get('accountExists?account='+this.value,function (data) {
                    if(data=='1'){
                        //存在
                        $('#account').next().html('该账号已存在');
                        $('#sub').attr('disabled',true);
                    } else{
                        // 不存在
                        $('#account').next().html('');
                        $('#sub').attr('disabled',false);
                    }
                });
            });


        });

    </script>

</body>
</html>













